package com.beyondbit.hr.demo;

import com.beyondbit.hr.api.dto.request.OrgUserQueryReq;
import com.beyondbit.hr.api.utils.HttpUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URL;
import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;

public class OrgUserDemo {

    public static void main(String[] args) throws Exception{
        Logger logger = LoggerFactory.getLogger(OrgUserDemo.class);

        String urlBase = "http://127.0.0.1:8080/api/";

        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        OrgUserQueryReq req = new OrgUserQueryReq();

        req.setCreateTimeBegin(df.parse("2019-01-01 00:00:00"));
        req.setOrgIds(Arrays.asList("123","122"));
        req.setPageSize(2);
        req.setPage(1);

        String json = new ObjectMapper().writeValueAsString(req);

        String rsp = HttpUtils.jsonPostRaw(new URL(urlBase+"demo/orgUsers"),json, Charset.forName("UTF-8"));

        System.out.println(rsp);


    }
}
